STEP 5: We're now set up to handle any error the user might cause with invalid input. Let's ask the question!

  • First delete x·=·5·/·0 underneath the try statement.
  • In GRAPHICS and , drag Ask for Integer inside the try statement, indented three times!
  • Change guess to scoops and change the question to "How many scoops would you like?"
  • Entering input that's not a number will cause a runtime error and stop the program. Can't have that happen!

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)